{include file="public/header" /} {include file="public/menu" /}
<div class="layui-tab layui-tab-brief" lay-filter="demoTitle">
    <ul class="layui-tab-title site-demo-title">
        <li  class="layui-this"><a href="{:url('banner/index')}">轮播图管理</a></li>
        <li><a href="{:url('banner/postdata')}">添加轮播图</a></li>
    </ul>
    <div class="layui-body layui-tab-content site-demo site-demo-body">

        <div class="layui-tab-item layui-show">
            <div class="layui-main">
                <div id="LAY_preview">
                    <table class="layui-table">
                        <thead>
                        <tr>
                            <th>图片</th>
                            <th>是否显示</th>
                            <th>排序</th>
                            <th>外链</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {volist name="banners" id="vo"}
                        <tr>
                            <td>
                                {if $vo.pic}
                                    <a target="view_window" title="点击查看原图" href="{$vo.pic}">
                                        <img src="{$vo.pic}" alt="">
                                    </a>
                                {/if}
                            </td>
                            <td>{$vo.status}</td>
                            <td>{$vo.displayorder}</td>
                            <td>{$vo.link}</td>
                            <td>
                                <a class="layui-btn layui-btn-mini" lay-event="edit" href="{:url('banner/postdata',['id'=>$vo.id])}">编辑</a>
                                <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del" href="javascript:data_del({$vo.id})">删除</a>
                            </td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>

                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function data_del(id) {
        layui.use(['layer','laypage'], function() {
            var layer = layui.layer,
                laypage = layui.laypage,
                $ = layui.$;

            laypage.render({
                elem: 'test1' //注意，这里的 test1 是 ID，不用加 # 号
                ,
                count: "50" //数据总数，从服务端得到
            });

            layer.confirm('确定删除？', {
                btn: ['确认', '取消']
            }, function(index, layero) {
                //按钮【按钮一】的回调
                $.post("{:url('banner/del')}", { id: id }, function(res) {
                    //res就是返回的结果
                    var res = JSON.parse(res)
                    if (res.status == 200) {
                        layer.msg(res.msg);
                        location.reload();
                    } else {
                        layer.msg(res.msg)
                    }
                });
            }, function(index) {
                //按钮【按钮二】的回调
            });
        })
    }
</script>
{include file="public/footer" /}